<template>
  <div class="section-wrap addPlan">
    <!-- 头部 -->
     <div class="headerBox">
    <div class="header">
      <x-icon type="ios-arrow-left" size="" class="icon-white" @click="goBack"></x-icon>
      新增检查记录
    </div>
    </div>
    <div class="form-section" style="margin-top: 40px;margin-bottom:0;">
      <div class="form-item form-item-style1">
        <div class="label-title">
          <label>被检查单位</label><i class="iconfont icon-required"></i>
        </div>
        <div class="input_div" @click="classValue = true">
          <input type="text"
                 placeholder="请选择"
                 :disabled="isDisabled" v-model="$store.state.addCheckRecord.projectName">
          <x-icon type="ios-arrow-right" size="22" class="icon-right" ></x-icon>
        </div>
      </div>
      <div class="form-item form-item-style1">
        <div class="label-title">
          <label>检查类型</label><i class="iconfont icon-required"></i>
        </div>
        <div class="input_div">
          <input type="text" v-model="params.checkType" placeholder="请选择" disabled style="padding-right:10px">
          <!-- <x-icon type="ios-arrow-right" size="22" class="icon-right" ></x-icon> -->
        </div>
      </div>
      <div class="form-item form-item-style1">
        <div class="label-title">
          <label>检查时间</label>
          <i class="iconfont icon-required"></i>
        </div>
        <group >
          <datetime placeholder="请选择"  v-model="params.checkDate" @on-change="checkDate()" format="YYYY-MM-DD" style="font-size:16px"></datetime>
        </group>
      </div>
      <div class="form-item form-item-style1">
        <div class="label-title">
          <label>检查表</label>
          <!-- <i class="iconfont icon-required"></i> -->
        </div>
        <div class="input_div" @click="classValue2=true">
          <input type="text"
                 placeholder="请选择"
                 v-model="$store.state.addCheckRecord.receivrtName"
          >
          <x-icon type="ios-arrow-right" size="22" class="icon-right" ></x-icon>
        </div>
      </div>
      <div class="form-item form-item-style1">
          <div class="label-title">
              <label>整改责任人</label>
              <i class="iconfont icon-required"></i>
          </div>
          <div class="input_div" @click="getGroup(1)">
              <input type="text"
              placeholder="请选择"
              disabled v-model="subData.zgZrrName">
              <x-icon type="ios-arrow-right" size="22" class="icon-right"></x-icon>
          </div>
      </div>
      <div class="form-item form-item-style1">
          <div class="label-title">
              <label>参与检查人</label>
              <!-- <i class="iconfont icon-required"></i> -->
          </div>
          <div class="input_div" @click="checkpersonValue=true">
              <input type="text"
              placeholder="请选择"
              disabled v-model="subData.PartakeCheckPerson">
              <x-icon type="ios-arrow-right" size="22" class="icon-right"></x-icon>
          </div>
      </div>
      <div class="form-item form-item-style2">
          <div class="label-title">
              <label>被检查地点</label>
          </div>
          <div >
              <textarea class="textarea" :max="500"  placeholder="请输入（可自动换行)"  maxlength="200" v-model="subData.CheckedPlaces"></textarea>
          </div>
      </div>
      <div class="form-item form-item-style2">
          <div class="label-title">
              <label>检查范围和内容</label>
          </div>
          <div >
              <textarea class="textarea" :max="500"  placeholder="请输入（可自动换行)"  maxlength="200" v-model="subData.CheckedRangeAndContent"></textarea>
          </div>
      </div>
      <div class="form-item form-item-style1">
        <div class="label-title">
          <label>更多</label>
          <!-- <i class="iconfont icon-required"></i> -->
        </div>
        <div class="input_div" @click="addGoComm">
          <input type="text"
                disabled
                 v-model="zginfos"
          >
          <x-icon type="ios-arrow-right" size="22" class="icon-right" ></x-icon>
        </div>
      </div>
      <!-- 检查记录 -->
      <div class="notice_div" style="display:">
        <!-- <div class="notice_top">
          <p>检查记录<span>（{{totalCount}}条）</span></p>
          <x-icon type="ios-arrow-down" size="22" class="icon-down"></x-icon>
        </div> -->
        <group>
            <cell
                    title="检查记录"
                    is-link
                    :border-intent="false"
                    :arrow-direction="showContent001 ? 'up' : 'down'"
                    @click.native="showContent001 = !showContent001" id="aa">
                    <span class="aaSpan">({{$store.state.totalCount}}条)</span>
            </cell>
            <template v-if="showContent001">
                <ul class="notice_list" v-for="(item,index) in $store.state.addCheckRecord.data4" :key="index">
                    <li v-for="(item2,index2) in item.safeJcSubject" :key="index2" @click="indexLi(index2)">
                        <div class="down_div">
                          <label>{{item2.jcSubjectName}} </label>
                          <div class="notice_item">
                              <span class="notice_number">{{item2.safeJcSubjectDetail.length}} </span>
                              <x-icon type="ios-arrow-up" size="22" class="icon-up"></x-icon>
                          </div>
                        </div>
                        <ul class="cList" v-if="ind==index2?true:false">
                          <li class="clearfix" v-for="(data,index) in item2.safeJcSubjectDetail" :key="index" @click="amend(data)">
                              <p>{{data.jcSubjectContent}} </p>
                              <x-icon type="ios-arrow-right" size="22" class="icon-right"></x-icon>
                          </li>
                        </ul>
                    </li>
                </ul>
            </template>
        </group>
      </div>
      <!-- 问题记录 -->
      <div class="notice_div" style="display:">
        <div class="notice_top" >
          <p>发现问题<span>（{{questioncount}}条）</span></p>
          <!-- <x-icon type="ios-plus-outline" size="22" class="icon-down" @click="addGo"></x-icon> -->
        </div>
        <Slide :isdelete="true" @hiddenfun="hiddenfun"  :listArr="list"></Slide>
      </div>
      <div class="form-item form-item-style1">
          <div class="label-title">
              <label>问题类别</label>
              <i class="iconfont icon-required"></i>
          </div>
          <div class="input_div" @click="questionValue=true">
              <input type="text"
                  placeholder="请选择"
                  disabled v-model="subData.hiddenDangerType">
              <x-icon type="ios-arrow-right" size="22" class="icon-right"></x-icon>
          </div>
      </div>
      <div class="form-item form-item-style2">
          <div class="label-title">
              <label>问题描述</label>
              <i class="iconfont icon-required"></i>
              <div class="input_div"  style="width:260px" @click="valueBtn3_2">
                  <input type="text"
                  placeholder="请选择"
                  disabled
                    style="float:right;margin-right:20px">
              </div>
          </div>
          <div @click="entdescription">
              <textarea  class="textarea"  placeholder="请输入（可自动换行)"  maxlength="200" v-model="subData.hiddenDangeDescription"></textarea>
          </div>
      </div>
      <div class="form-item form-item-style2">
              <div class="label-title space-between">
              <label>整改前图片<i class="iconfont icon-required"></i></label>
              <!-- <span>当前共{{detailinfo.projectImgList!=null?detailinfo.projectImgList.length:0}}张照片</span> -->
          </div>
          <div class="upload-wrap">
              <upload ref="child"
              :imgList="projectImgList1.rectifyImgList"
              @setFormData="setYSFormData"
              ></upload>
          </div>
      </div>
      <div class="form-item form-item-style2">
          <div class="label-title">
              <label>整改要求</label>
              <i class="iconfont icon-required"></i>
          </div>
          <div @click="amend4">
              <textarea class="textarea" placeholder="请输入（可自动换行）" v-model="subData.measure"></textarea>
          </div>
      </div>
      <div class="form-item form-item-style1">
          <div class="label-title">
              <label>整改期限</label>
              <i class="iconfont icon-required"></i>
          </div>
          <group>
              <datetime placeholder="请选择" :max="500" format="YYYY-MM-DD" v-model="subData.zgEndTime"></datetime>
          </group>
      </div>
      <!-- <div style="margin: 0 auto;padding-left: 17px;width: 50%;" class="form-item form-item-style1">
        <el-button  @click="save">继续添加整改问题</el-button>
      </div> -->
        <div class="btns">
           <p class="transfer_p"><span style="width:171px" @click="handleSubmit()">继续添加整改问题</span> </p>
        </div>
      <!-- 生成通知单 -->
      <div class="details">
        <div class="details_top">
          <p>生成通知单</p>
          <!-- <x-icon type="ios-arrow-up" size="22" class="icon-up"></x-icon> -->
        </div>
        <ul class="details_list">
          <li style="height: 115px;" v-for="(item,index) in alertList" :key="index" @click="routerGo(item)">
            <label>{{item.name}} </label>
            <div class="details_item">
              <x-icon type="ios-arrow-right" size="22" class="icon-right"></x-icon>
            </div>
              <div v-if="item.type==1">
              <flow v-if="questioncount>0&&zgcount==0">
                <flow-state state="1" title="已登记问题" is-done></flow-state>
                <flow-line tip="未选择"></flow-line>
                <flow-state state="2" title="已选择"></flow-state>
              </flow>
              <flow v-if="questioncount>0&&zgcount>0">
                <flow-state state="1" title="已登记问题" is-done></flow-state>
                <flow-line is-done></flow-line>
                <flow-state state="2" title="已选择" is-done></flow-state> 
              </flow>
              <flow  v-if="questioncount==0">
                <flow-state state="1" title="未登记问题" is-done></flow-state>
                <flow-line></flow-line>
                <flow-state state="2" title="已选择"></flow-state>
              </flow>
              </div>
              <div v-if="item.type==2">
              <flow v-if="questioncount>0&&xfcount==0">
                <flow-state state="1" title="已登记问题" is-done></flow-state>
                <flow-line tip="未选择"></flow-line>
                <flow-state state="2" title="已选择"></flow-state>
              </flow>
              <flow v-if="questioncount>0&&xfcount>0">
                <flow-state state="1" title="已登记问题" is-done></flow-state>
                <flow-line is-done></flow-line>
                <flow-state state="2" title="已选择" is-done></flow-state> 
              </flow>
              <flow  v-if="questioncount==0">
                <flow-state state="1" title="未登记问题" is-done></flow-state>
                <flow-line></flow-line>
                <flow-state state="2" title="已选择"></flow-state>
              </flow>
              </div>
          </li>
        </ul>
      </div>
      <div class="btns_div">
        <a class="submitBtn" @click="confirmsubmit">提 交</a>
        <a class="cancelBtn" @click="cannal">取 消</a>
      </div>
      
    </div>
    <div v-transfer-dom>
      <!-- 被检查单位 -->
      <popup v-model="classValue" width="100%">
        <ztree
          :data="data"
          @nodeClick="nodeClick"
          :name="'departName'"
        ></ztree>
      </popup>
           <!-- 检查表 -->
      <popup v-model="classValue2" width="100%" >
          <ul class="popList">
              <li :class="ind==index ? 'active' : ''" v-for="(item,index) in data3" :key="index" @click="selectLi(index,item)">
                  <p>{{item.type}}<img src="../../../static/images/list_checked.png"></p>
              </li>
          </ul>
      </popup>
      <!-- 检查记录修改 -->
      <popup v-model="classValue3" width="100%" height="300px">
          <group>
                <x-textarea :max="200" :rows="7" name="description" placeholder="请输入" v-model="checkData" id="tt"></x-textarea>
          </group>
          <p class="transfer_p"><span @click="ent">确定</span> <em @click="clear">清空</em></p>
      </popup>
      <popup v-model="classValue4" width="100%" height="300px">
        <ul>
          <li></li>
        </ul>
      </popup>
      <!-- 问题类别 -->
      <popup v-model="questionValue" width="100%">
          <div id="classValue2">
              <!-- <group>
                  <radio :options="radio002" @on-change="change2"></radio>
              </group> -->
              <ul class="popList">
                  <li :class="ind3==index ? 'active' : ''" v-for="(item,index) in radio002" :key="index" @click="change2(item,index)">
                      <p>{{item}}<img src="../../../static/images/list_checked.png"></p>
                  </li>
              </ul>
          </div>
      </popup>
      <!-- 问题描述 -->
      <popup v-model="classValue3_2" width="100%">
          <div class="divClass" id="classValue2">
              <ul class="hiddden">
                  <li :class="ind4==index ? 'active' : ''" v-for="(item,index) in radio003" :key="index" @click="change3(item,index)">
                      <p>{{item}}</p>
                      <img src="../../../static/images/list_checked.png">
                  </li>
              </ul>
          </div>
      </popup>
      <popup v-model="classValue11" width="100%" height="300px">
          <group>
                  <x-textarea :max="200" :rows="7" name="description" placeholder="请输入" v-model="checkData11" id="tt"></x-textarea>
          </group>
          <p class="transfer_p"><span @click="ent11">确定</span> <em @click="clear11">清空</em></p>
      </popup>
      <!-- 整改责任人 -->
      <popup v-model="classValue5" width="100%" >
          <select-depart :data="data2" @selectUser='selectUser'></select-depart>
      </popup>
      <!-- 参与检查人 -->
      <popup v-model="checkpersonValue" width="100%" height="60%" style="padding-bottom:40px;">
        <div style="background: white;height:100%;overflow-y:scroll;padding-bottom:20px;">
          <el-tree
            v-if="checkpersonValue"
            :data="data"
            node-key="id"
            :render-content="renderContent"
            :expand-on-click-node="true"
            ref="tree1"
            :props="defs"
          ></el-tree>
          <div style="text-align:  center;margin-top: 10px;padding-bottom: 5px;position: absolute;width: 100%;bottom: 15px;background-color: #eee;z-index: 10;">
            <el-button size="mini" @click="checkpersonValue=false">取消</el-button>
            <el-button size="mini"  @click="addUser">确认</el-button>
          </div>
        </div>
      </popup>
    </div>
    <el-dialog   :visible.sync="isshow"   width="90%" center>
      <div  class="form-item form-item-style1">
          <div class="label-title">
              <label>问题类别</label>
          </div>
          <div class="input_div" >
               <p>{{datainfo.hiddenDangerType}}</p>
          </div>
      </div>
      <div  class="form-item form-item-style2">
          <div class="label-title">
              <label>问题描述</label>
          </div>
          <div class="input_div">
              <span>{{datainfo.hiddenDangeDescription}}</span>
          </div>
      </div>
      <div  class="form-item form-item-style2">
        <div class="label-title space-between">
          <div class="space-between">
            <label>整改前图片</label>
          </div>
          <span>当前共{{datainfo.projectImgList != null ? datainfo.projectImgList.length: 0}}张照片</span>
        </div>
        <div>
          <div 
          >
            <div 
                 v-for="(item,index) in datainfo.projectImgList"
                 :key="index">
              <img :src="item.url" style="height:60px;width:60px"
                   @click="previewImg(item.url)"
                   alt="">
            </div>
          </div>
        </div>
      </div>
      <div  class="form-item form-item-style2">
          <div class="label-title">
              <label>整改要求</label>
          </div>
          <div class="input_div">
              <span>{{datainfo.measure}}</span>
          </div>
      </div>
      <div class="form-item form-item-style1">
          <div class="label-title">
              <label>整改期限</label>
          </div>
          <div class="input_div">
             <p>{{datainfo.zgEndTime}}</p>
          </div>
      </div>
    </el-dialog>
    <div v-transfer-dom>
      <confirm v-model="isconfirm"
      title="是否添加问题？"
      confirm-text="是"
      cancel-text="否"
      @on-cancel="save"
      @on-confirm="tolsave">
      </confirm>
    </div>
  </div>
</template>
<script>
  import Slide from './slide';
  import CellBox from './cell';
  import ztree from "@commonComponents/tree"
  import upload from "@/commonComponents/upload/upload";
  import selectDepart from "@commonComponents/selectDepartUser/selectUser";
  import {Flow, FlowState, FlowLine,XHeader, Tabbar, TabbarItem,Confirm, Group, Cell, TransferDomDirective as TransferDom, Popup} from 'vux';
  export default {
    data() {
      return {
        isconfirm:false,
        isok:false,
        isshow:false,
        ids:[],
        checkpersonValue:false,
        alertList:[
          {name:'生成电网工程建设安全稽查整改通知单',type:1},
          {name:'生成安全检查违章记分通知书',type:2},
        ],
        zginfos:'安全稽查整改基本信息',
        amendId:'',
        addObj:{},
        ind:9999,
        list:[],
        total:'0',
        showContent: false,
        showContent001: true,
        showContent002: false,
        totalCount:'0',
        groupIndex:0,
        entIndex:1,
        checkArea:'',
        ind:0,
        ind2:0,
        ind3:9999,
        ind4:9999,
        num:0,
        checkedList: [],
        lis: [],
        index: '',
        dataList: [],
        isDisabled: true, // 是否禁止输入
        classValue: false,
        classValue2: false,
        classValue3: false,
        classValue4: false,
        classValue5: false,
        questionValue:false,
        classValue3_2:false,
        checkData11:'',
        classValue11:false,
        radio002:[],
        radio003:[],
        subData:{
            type:'dj',
            checkworkId:''
        },
        datainfo:{},
        flag: false,
        selectImg: '',
        params: {
          status: 1,
        },
        data: [],
        data2: [],
        data3: [],
        data4: [],
        checkIdea:'',
        params2:{
          name:'',
          jcType:'',
          skipCount:0,
          maxResultCount:10000
        },
        checkData:'',
        arrList2:[],
        projectImgList1:[],
        questioncount:'',
        zgcount:0,
        xfcount:0,
        defs: {
          children: 'children',
          label: "departName"
        },
        itemId:'',
        peosonlist:[],
      }
    },
    components: {
      ztree, Popup,Slide,CellBox,upload,selectDepart,Confirm,Flow,FlowState,FlowLine
    },
    directives: {
      TransferDom
    },
    created() {
      if(JSON.stringify(this.$store.state.xfinfo) != "{}" && JSON.stringify(this.$store.state.xfinfo) !="null") {
        this.subData = this.$store.state.xfinfo
      }
      this.$store.state.addCheckRecord.receivrtName = "无"
      this.getList()
      this.examinedUnits()
      this.params.checkType=this.$route.query.name
      var p={
        planId:this.$route.query.id
      }
      // 获取保留时间
      if (this.$store.state.addCheckRecord.checkDate){
        this.params.checkDate=this.$store.state.addCheckRecord.checkDate
      }
      // 获取检查记录的数据
      if (this.$store.state.addCheckRecord.data4){
        this.data4=this.$store.state.addCheckRecord.data4
      }
      // 修改后的数组
      if (this.$store.state.amend){
        this.data4=this.$store.state.amend
      }
      
      this.data3=this.$store.state.data3?this.$store.state.data3:[]
      this.getPlanList()
      this.change0()
      // 获取整改责任人员接口
      this.$axiosAjax.getDivision({classifyId: ''}).then((res) => {
          if (res.data.success == true) {
              this.data2 = res.data.result
          }
      }).catch((err) => {
          console.log(err)
          }
      )
    },
    methods: {
        confirmsubmit () {
          //判断是否添加过隐患  如果没有则弹出提示框
          if(!this.isok || !this.$store.state.xfisok) {
            this.isconfirm=true
          } else {
            this.save()
          }
          // this.$confirm('是否添加问题?', '提示', {
          //                   confirmButtonText: '是',
          //                   cancelButtonText: '否',
          //                   type: 'warning',
          // }).catch(_ => {

          // })

        },
        previewImg(url){//图片预览
          this.selectImg=url
          this.flag=true
        },
        hiddenfun (data) {
          this.isshow = true
          this.datainfo = data
          this.datainfo.zgEndTime = this.datainfo.zgEndTime.substring(0,10)
          // this.showContent002 = !this.showContent002
        },
        // 参与检查人
        append (data) {
          if (!data.children) {
            this.$set(data, 'children', [])
          }
          var a =this.peosonlist
          if(a.length>0){
            a.forEach((item,i)=>{
              data.children.unshift({ id: item.id, departName: item.userName,type:"0", children: [] })
            })
          }
        },
        renderContent (h, { node, data, store }) {
          if(data.type=='0'){
            return (
              <span class="span">
              <span>
              <span class="ll" on-click={ () => this.nodeClicks(data) }>
              <el-checkbox on-change={ () => this.test(data) }>{node.label}</el-checkbox></span>
          </span>
            </span>
          )

          }else{
            return (
              <span class="span">
              <span>
              <span on-click={ () => this.nodeClicks(data) }>{node.label}
          </span>
            </span>
            </span>
          )
          }
        },
        test(data){
          if(this.ids.indexOf(data)==-1){
            this.ids.push(data)
          }else{
            this.ids.splice(data,1)
          }
        },
        addUser(){
          this.checkpersonValue=false
          if(this.ids.length>0){
            // this.params.receiverId = this.ids.map(x => x.id).join(',');
            this.subData.PartakeCheckPerson = this.ids.map(x => x.departName).join(',');
          }
        },
        nodeClicks(item) {
          if(this.itemId==item.id){
            return;
          }
          if(item.type=='0'){
            return;
          }
          this.itemId=item.id
          this.$axiosAjax.getUserList({departId:item.id}).then((res) => {
            if(res.data.success==true){
              if(res.data.result.totalCount>0){
                console.log(res.data.result)
                this.peosonlist = res.data.result.items;
                this.append (item)
              }
            }
          }).catch(
            (err)=>{

            }
          )
        },
        entdescription () {
           this.subData.measure = '及时整改'
        },
        //当选择新增问题 则提交两个
        tolsave() {
          this.handleSubmit(true)
        },
        // 提交
        handleSubmit (ishidden) {
            this.$axiosAjax.getHiddenInfo({}).then((res) => {
                if (res.data.success == true) {
                    this.subData.checkDeptName=res.data.result.checkDeptName // 检查单位
                    this.subData.checkDeptId=res.data.result.checkDeptId // 检查单位id
                    this.subData.checkPerson=res.data.result.checkPerson // 检查人
                    this.subData.telephone=res.data.result.telephone // 电话
                    this.subData.checkTime=res.data.result.checkTime // 检查时间
                    this.subData.parentDeptName=res.data.result.parentDeptName // 所属上级单位
                    this.subData.parentDeptId=res.data.result.parentDeptId // 所属上级单位
                    this.subData.hiddenDangerLevel = "一般问题"
                    this.subData.projectType = '00000000-0000-0000-0000-000000000000'
                    this.subData.bcheckDeptName = this.$store.state.addCheckRecord.projectName
                    this.subData.bcheckDeptId= this.$store.state.addCheckRecord.projectId    // 参建单位ID
                    this.subData.bcheckDeptFzr=this.params.charge      // 被检查单位负责人
                    this.subData.zgStartTime = this.params.checkDate+ " 00:00:00";
                    this.subData.checkworkId=this.$route.query.id
                    if(this.subData.bcheckDeptName&&
                        this.subData.hiddenDangerType&&
                        this.subData.hiddenDangeDescription&&
                        this.subData.measure&&
                        this.subData.zgStartTime&&
                        this.subData.zgEndTime&&
                        this.subData.zgZrrName&&
                        this.subData.fileList&&
                        this.subData.fileList.length != 0
                    ){
                      this.subData.zgEndTime = this.subData.zgEndTime + " 00:00:00";
                      this.$axiosAjax.submitHiddenDangerInfoAPP(this.subData).then((res) => {
                            if (res.data.success == true) {
                                if(ishidden) {
                                  this.save()
                                } else {
                                  this.isok = true
                                  this.$vux.toast.text('提交成功')
                                }
                                //清空
                                this.subData.hiddenDangerType = ''
                                this.subData.hiddenDangeDescription = ''
                                this.subData.measure= ''
                                this.subData.zgEndTime = ''
                                this.subData.fileList = []
                                this.projectImgList1.rectifyImgList = []
                                this.$refs.child.clearimage() //清空子组件附件集合
                                this.getPlanList() // 刷新问题记录
                            }
                        }).catch((err) => {
                            console.log(err)
                            }
                        )
                    } else if(!this.subData.bcheckDeptName){
                        this.$vux.toast.text('被检查单位不能为空')
                    }else if(!this.subData.hiddenDangerType){
                        this.$vux.toast.text('问题类别不能为空')
                    }else if(!this.subData.hiddenDangeDescription){
                        this.$vux.toast.text('问题描述必填')
                    }else if(!this.subData.measure){
                        this.$vux.toast.text('整改要求必填')
                    }else if(!this.subData.zgStartTime){
                        this.$vux.toast.text('检查时间不能为空')
                    }else if(!this.subData.zgEndTime){
                        this.$vux.toast.text('整改期限不能为空')
                    }else if(!this.subData.zgZrrName){
                        this.$vux.toast.text('整改责任人必填')
                    }else if(!this.subData.fileList || this.subData.fileList.length == 0){
                        this.$vux.toast.text('整改前图片必传')
                    }
                }
            }).catch((err) => {
                console.log(err)
                }
            )
        },
        // 获取人员数据
        getGroup (index) {
            this.groupIndex=index
            this.classValue5 = true;
        },
        // 人员选择
        selectUser(data) {
            if (this.groupIndex==1){  // 整改责任人
                this.subData.zgZrrName=data.userName
                this.subData.zgZrrId=data.userAccount
            } else if (this.groupIndex==2){  // 参与检查人
                this.subData.PartakeCheckPerson=data.userName
                // this.subData.copytoPersonId=data.id
            }
            this.classValue5 = false
        },
        valueBtn3_2(){
            if(this.subData.hiddenDangerType){
                this.classValue3_2=true
            }else if(!this.subData.hiddenDangerType){
                this.$vux.toast.text('先选择问题类别')
            }
        },
        amend4(){
            this.classValue11=true
            this.checkData11=this.subData.measure
        },
        ent11 (){
            this.classValue11=false
            this.subData.measure=this.checkData11
        },
        clear11(){
            this.classValue11=false
        },
        setYSFormData (setFormDatalength, file) {
            console.log(setFormDatalength, file,121)
            // this.YSFormData = formData;
            var arr =[]
            for (var k of file){
                arr.push(k.id)
            }
            this.subData.fileList=arr
        },
        //初始加载 根据项目类型获取问题类别
        change0 (value, index) {
            this.$axiosAjax.getHiddenDangerStatus2({hiddrenTypeId:'00000000-0000-0000-0000-000000000000'}).then((res) => {
                if (res.data.success == true) {
                    var list =res.data.result
                    this.arrList2=list
                    var arr=[]
                    for(var k of list){
                        arr.push(k.type)
                    }
                    this.radio002=arr
                }
            }).catch((err) => {
                console.log(err)
                }
            )
        },
        // 问题类别
        change2 (value, index) {
            this.ind3=index
            this.subData.hiddenDangerType=value
            this.questionValue=false
            var id=''
            for (var k of this.arrList2){
                if (k.type==value){
                    id=k.id
                }
            }
            this.$axiosAjax.getStandard({parentId:id}).then((res) => {
                if (res.data.success == true) {
                    var list =res.data.result.items
                    this.arrList3=list
                    var arr=[]
                    for(var k of list){
                        arr.push(k.checkStandard)
                    }
                    this.radio003=arr
                    //同时清空 问题描述和措施
                     this.subData.hiddenDangeDescription=''
                     this.subData.measure=''
                }
            }).catch((err) => {
                console.log(err)
                }
            )
        },
        change3 (value, label) {
            this.ind4 = label
            this.subData.hiddenDangeDescription=value
            this.classValue3_2=false
            this.subData.hiddenDangeDescription=value
            for(var k of this.arrList3){
                if (k.checkStandard==value){
                    this.subData.measure=k.resolveMeasure
                }
            }
            this.classValue3_2=false
        },
      // 添加问题按钮
      addGo(){
        if (this.$store.state.addCheckRecord.projectName){
          this.$router.push({path:'./registerDanger',query:{id:this.$route.query.id}})
        }else {
          this.$vux.toast.text('先选择被检查单位')
        }
      },
      addGoComm(){
        if (this.$store.state.addCheckRecord.projectName){
          //跳转前 保证当前页面
          this.$store.state.xfinfo = this.subData
          this.$store.state.xfisok =this.isok
          this.$router.push({path:'./registerDangerNew',query:{id:this.$route.query.id}})
        }else {
          this.$vux.toast.text('先选择被检查单位')
        }
      },
      // 点击生成通知单
      routerGo(item){
        // if(this.list.length>0){
        //   this.$router.push({path:'./safeNotice',query:{name:item.name,type:item.type,id:this.$route.query.id}})
        // }else {
        //   this.$vux.toast.text('先添加问题才能生成通知单')
        // }
        //跳转前 保证当前页面
        this.$store.state.xfinfo = this.subData
        this.$store.state.xfisok =this.isok
        this.$router.push({path:'./safeNotice',query:{name:item.name,type:item.type,id:this.$route.query.id}})
      },
      indexLi(index){
        this.ind=index
      },
      // 时间选择
      checkDate(){
        this.$store.state.addCheckRecord.checkDate=this.params.checkDate
      },
      goBack() {
        this.$store.state.xfinfo=null
        this.$router.go(-1)
      },
      add() {//增加按钮
        let cope = {name: ""}
        this.lis.push(cope);
      },
      // 被检查单位
      examinedUnits() {
        this.$axiosAjax.examinedUnits({parentId: this.$store.state.departId}).then((res) => {
          if (res.data.success == true) {
            this.data = res.data.result
          }
        }).catch((err) => {
          console.log(err)
          }
        )
      },
      // 问题记录
      getPlanList() {
        var p={
            skipCount:0,
            maxResultCount:10000,
            checkworkId:this.$route.query.id
        }
        this.$axiosAjax.getHiddenPageList(p).then((res) => {
          if (res.data.success == true) {
            var list =res.data.result.items
            for (var k of list){
              if (k.projectImgList.length>0){
                k.imgUrl=k.projectImgList[0].url
              }  else {
                k.imgUrl=''
              }
            }
           
            this.$nextTick(() =>{ this.questioncount=list.length })
            this.list=list
            if(this.list.length>0) {
              this.isok = true
              this.$store.state.xfisok =this.isok
            }
          }
        }).catch((err) => {
          console.log(err)
          }
        )

        //同时判断是否 有选择下发内容
        if(this.$store.state.addCheckRecord.noticesIds2!=null) {
          this.xfcount = this.$store.state.addCheckRecord.noticesIds2.length
        }
        if(this.$store.state.addCheckRecord.noticesIds!=null) {
          this.zgcount = this.$store.state.addCheckRecord.noticesIds.length
        }
      },
      // 点击单位树
      nodeClick(item){
        if(item.departType==6||item.departType==7||item.departType==8){
          this.$store.state.addCheck=item
          this.params.projectName=item.departName
          this.params.projectId=item.id
          this.$store.state.addCheckRecord.projectId=item.id
          this.$store.state.addCheckRecord.projectName=item.departName
          this.classValue=false
        } else {
          this.classValue=false
          this.$vux.toast.text('只能选择项目')
        }
        this.params.projectType = item.projectType
      },
      // 检查表
      getList(){
        this.params2.jcType=this.$route.query.name
        this.$axiosAjax.getIndex(this.params2).then((res) => {
          if (res.data.success == true) {
            var list =res.data.result.items
            var arr =[]
            for (var k of list){
              var obj ={}
              obj.type=k.jcName
              obj.id=k.id
              arr.push(obj)
            }
            arr.unshift({
              type:'无',
              id:'无'
            })
            this.data3=arr
            this.$store.state.data3=arr
          }
        }).catch((err) => {
          console.log(err)
          }
        )
      },
      selectLi(index,item) {
        this.ind=index
        this.params.receivrtName=item.type
        this.$store.state.addCheckRecord.receivrtName=item.type
        this.$store.state.addCheckRecord.checkClassId=item.id
        this.classValue2=false
        this.params2.name=item.type
        this.$axiosAjax.getIndex(this.params2).then((res) => {  // 检查记录
          if (res.data.success == true) {
            console.log(res.data.result.items,122)
            if(item.type == '无') {
              this.$store.state.totalCount = 0
              this.$store.state.addCheckRecord.data4 = []
            } else {
              this.$store.state.totalCount=res.data.result.items[0].safeJcSubject.length
              this.data4 =res.data.result.items
              this.$store.state.addCheckRecord.data4=res.data.result.items
              if(res.data.result.items.length>0){ // 数据加载后,展开记录
                this.showContent001=true
              }
            }

          }
        }).catch((err) => {
          console.log(err)
          }
        )
      },
      // 点击修改检查记录
      amend(data){
        this.amendId = data.id
        this.classValue3=true
        this.checkData=data.checkResult
      },
      // 确定修改
      ent(){
        var list = this.$store.state.addCheckRecord.data4
        for (var i of list){
          for(var k of i.safeJcSubject){
            for (var j of k.safeJcSubjectDetail){
              if (j.id==this.amendId){
                j.checkResult=this.checkData
              } 
            }
          }
        }
        // this.data4=list
        this.$store.state.amend=list
        this.showContent001=true
        this.classValue3=false
        // this.$forceUpdate()
      },
      clear(){
        this.checkData=''
      },
      // 提交
      save(){
        
        let userInfo = JSON.parse(localStorage.getItem('userInfo'))
        this.params.id =  this.$route.query.id
        this.params.projectId=this.$store.state.addCheckRecord.projectId
        this.params.projectName=this.$store.state.addCheckRecord.projectName
        this.params.teamLeaderId = userInfo.id
        this.params.teamLeader =  userInfo.userName
        this.params.charge =  ''
        this.params.noticeData={
          '1':this.$store.state.addCheckRecord.noticesIds,
          '2':this.$store.state.addCheckRecord.noticesIds2,
          '3':this.$store.state.addCheckRecord.noticesIds3,
          '4':this.$store.state.addCheckRecord.noticesIds4
        }
        this.params.IllegalSandardId = this.$store.state.addCheckRecord.IllegalSandardId
        this.params.IllegalSandardName = this.$store.state.addCheckRecord.IllegalSandardName
        this.params.PushDeptId = this.$store.state.addCheckRecord.PushDeptId
        this.params.PushDeptName = this.$store.state.addCheckRecord.PushDeptName
        this.params.checkClassName=this.$store.state.addCheckRecord.receivrtName
        this.params.checkClassId=this.$store.state.addCheckRecord.checkClassId
        // this.params.checkType = this.$route.query.type+','+this.params.checkType
        var a=[]
        a.push(this.$route.query.type)
        a.push(this.$route.query.name)
        this.params.checkType = a
        this.params.isPlan = 0
        let isAllInput = true
       // debugger
        if(this.params.projectName&&this.params.checkDate&&this.params.checkClassName){
          if(this.$store.state.addCheckRecord.data4!=null && this.$store.state.addCheckRecord.data4.length!=0) {
            var list=this.$store.state.addCheckRecord.data4[0].safeJcSubject
            var arr =[]
            for(var k of list){
              var obj ={}
              obj.divisionProsonId= userInfo.id
              obj.divisionProsonName= userInfo.userName
              obj.standardIdList=k.id
              obj.standardNameList=k.jcSubjectName
              obj.contentList=[]
              for(var j of k.safeJcSubjectDetail){
                var obj2={}
                obj2.checkContent=j.jcSubjectContent
                obj2.checkResult=j.checkResult
                if (!j.checkResult) {
                  isAllInput = false
                }
                obj.contentList.push(obj2)
              }
                arr.push(obj)
            }
            this.params.divisionList= arr
            
            if (!isAllInput) {
              this.$vux.toast.text('检查记录不能为空')
              return false
            }
          } else {
            this.params.divisionList = null
          }
          this.params.checkDate = this.params.checkDate + " 00:00:00";
          this.$axiosAjax.creatPlan(this.params).then((res) => {
            if (res.data.success == true) {
              this.$router.push('./safeCheckIndex')
              this.$store.state.addCheckRecord=[]
              this.$store.state.xfinfo=null
              this.$store.state.xfisok = false
              this.$vux.toast.text('提交成功')
            }else{
              this.$vux.toast.text(res.data.result)
            }
          }).catch((err) => {
            console.log(err)
            }
          )
        }else if (!this.params.projectName){
          this.$vux.toast.text('被检查单位必填')
        }else if (!this.params.checkDate){
          this.$vux.toast.text('检查时间必填')
        }else if (!this.params.checkClassName){
          this.$vux.toast.text('检查表必填')
        }
      },
      cannal(){
        // this.$router.push('./safeCheckIndex')
        this.$router.go(-1)
        this.$store.state.addCheckRecord=[]
      }
    },
  }
</script>
<style lang="less" scoped>
#classValue2{
  .popList {
    height: 224px;
    li {
        height: 46px;
        border-bottom: 1px solid #f0f1f5;
        position: relative;
        background-color: #fff;
        p {
            width: 100%;
            height: 45px;
            line-height: 45px;
            position: absolute;
            left: 50%;
            top: 0;
            transform: translate(-50%, 0);
            font-size: 14px;
            margin-left: 12px;
            text-align: center;
           
            img {
                height: 14px;
                width: 14px;
                margin-left: 10px;
                vertical-align: middle;
                position: relative;
                top: -1px;
                opacity: 0;
            }
        }
    }
    li.active {
        p {
        color: #469b7a;
        }
        img {
        opacity: 1;
        }
    }
  }
  &.divClass {
      width: 100%;
      height: 300px;
      overflow-y: scroll;
      .hiddden {
            li.active {
            p {
            color: #469b7a;
            }
            img {
            opacity: 1;
            }
        }
          li {
              min-height: 46px;
              border-bottom: 1px solid #f0f1f5;
              position: relative;
              background-color: #fff;
              padding: 20px 0;
              p {
                  width: 90%;
                  box-sizing: border-box;
                  display: inline-block;
                  padding: 0 10px 0 20px;
              }
              img {
                  height: 14px;
                  width: 14px;
                  vertical-align: middle;
                  position: relative;
                  top: -10px;
                  opacity: 0;
              }
          }
      }
  }
}
.divClass{
    width: 100%;
    min-height: 300px;
    overflow-y: scroll;
    .weui-cells_radio .weui-check__label{
        max-height: 60px;
        background-color: pink;
    }
}
.divClass2{
    width: 100%;
    min-height: 300px;
    position: relative;
    #divClass2{
        height: 260px;
        overflow-y: scroll;
    }
    p{
        height: 30px;
        width: 100%;
        position: absolute;
        padding: 0 20px;
        bottom: 4px;
        span,em{
            width: 60px;
            height: 30px;
            text-align: center;
            line-height: 30px;
            font-size: 16px;
            border-radius: 5px;
            color: #fff;
        }
        span{
            float: left;
            background-color:#2abf72;
        }
        em{
            float: right;
            background-color: #ceaa6c;
        }
    }
}
  .addPlan{
    overflow-x: hidden;
      .weui-cells:before{
      height: 20px;
      color: #fff!important;
    }
  }
  .weui-cell{
    // padding-left: 0!important;
    border-bottom: 1px solid #ebeef2;
  }
  .weui-cell_access .weui-cell__ft{
    padding-right: 20px;
  }
  .form-item {
    .input_div {
      .vux-x-icon {
        fill: #999;
        float: right;
        margin-top: 17px;
      }
    }
  }
  .info_div3 {
    height: 55px;
    line-height: 45px;
    padding: 0 20px;
    border-top: 10px solid #ebeef2;
    p {
      float: left;
      color: #469b7a;
      font-size: 16px;
      font-weight: bold;
    }
    .add_team {
      float: right;
      display: block;
      font-size: 14px;
      background: url("/static/images/add_new_icon.png") no-repeat right center;
      background-size: 16px 16px;
      padding-right: 20px;
      color: #999;
    }
  }
  .btns_div {
    width: 100%;
    background: #ebeef2;
    padding: 30px 20px 55px;
    justify-content: space-between;
    display: flex;
    a {
      height: 40px;
      border-radius: 20px;
      display: inline-block;
      width: 140px;
      text-align: center;
      line-height: 40px;
      color: #fff;
    }
    .submitBtn {
      background: #469b7a;
    }
    .cancelBtn {
      background: #f59b79;
    }
  }
  .vux-cell-placeholder{
    font-size: 14px;
    margin-right: 20px!important;
  }
  .addPlan .input_div input{
    width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .weui-cell__bd{
      height: 200px!important;
  }
  #tt {
      background-color: #eee;
      height: 220px;
      .weui-cell__bd .weui-textarea{
          height: 180px!important;
          background-color: pink;
      }
  }
  .weui-cell_access .weui-cell__ft{
    padding-right: 20px;
  }
  .popList {
    min-height: 200px;
    overflow-y: scroll;
    li {
      height: 40px;
      border-bottom: 1px solid #eee;
      background-color: #fff;
      position: relative;
      p {
        width: 100%;
        height: 40px;
        line-height: 40px;
        position: absolute;
        left: 50%;
        top: 0;
        transform: translate(-50%, 0);
        font-size: 14px;
        text-align: center;
        img {
          height: 14px;
          width: 14px;
          margin-left: 10px;
          vertical-align: middle;
          position: relative;
          top: -1px;
          opacity: 0;
        }
      }
    }
    li.active {
      p {
        color: #469b7a;
      }
      img {
        opacity: 1;
      }
    }
  }
  .details {
    border-top: 10px solid #ebeef2;
  .details_top {
    border-bottom: 1px solid #ebeef2;
    height: 45px;
    line-height: 44px;
    padding-right: 20px;
    margin-left: 20px;
    background: #fff;
    p {
      float: left;
      color: #469b7a;
      font-size: 16px;
      font-weight: bold;
    }

    .vux-x-icon {
      fill: #999;
      float: right;
      margin-top: 12px;
    }
  }
   .details_list {
      padding-left: 20px;
    .vux-x-icon {
      fill: #999;
      float: right;
      margin-top: 16px;
    }

    li {
      justify-content: space-between;
      border-bottom: 1px solid #ebeef2;
      
      padding-right: 20px;
      label {
        display: block;
        float: left;
        height: 54px;
        line-height: 54px;
      }

      .details_item {
        float: right;
        .vux-x-icon {
          fill: #999;
          float: right;
          margin-top: 16px;
        }
      }
    }

    li:last-child {
      border-bottom: none;
    }
  }
  }
  .notice_div {
    border-top: 10px solid #ebeef2;
    padding-left: 20px;

    .notice_top {
      border-bottom: 1px solid #ebeef2;
      height: 45px;
      line-height: 44px;
      padding-right: 20px;
      p {
        float: left;
        color: #469b7a;
        font-size: 16px;
        font-weight: bold;
        span{
          color: #999;
          font-weight: bold;
        }
      }
      .vux-x-icon {
        fill: #999;
        float: right;
        margin-top: 12px;
      }
      
    }
    .notice_top:nth-of-type(1){
      .vux-x-icon{
        fill: #12bd26;
      }
    }
    .notice_list {
        >li {
          .down_div{
            justify-content: space-between;
            border-bottom: 1px solid #ebeef2;
            height: 55px;
            padding-right: 20px;
            label {
              display: block;
              float: left;
              height: 54px;
              line-height: 54px;
              font-weight: bold;
              font-size: 15px;
              width: 290px;
              white-space: nowrap;/*内容超宽后禁止换行显示*/
              overflow: hidden;/*超出部分隐藏*/
              text-overflow:ellipsis;/*文字超出部分以省略号显示*/
            }
            .notice_item {
              float: right;
              .notice_number {
                background: #469b7a;
                color: #fff;
                height: 16px;
                width: 16px;
                border-radius: 50%;
                display: inline-block;
                text-align: center;
                line-height: 16px;
                font-size: 12px;
                margin-top: 19px;
              }
              .vux-x-icon {
                fill: #999;
                float: right;
                margin-top: 16px;
              }
            }
          }
          .cList{
            li{
              justify-content: space-between;
              border-bottom: 1px solid #ebeef2;
              align-items: center;
              display: flex;
              padding: 6px 12px 6px 0;
              font-size: 14px;
              padding-left: 10px;
              p{
                float: left;
                width: calc(100% - 40px);
                line-height: 20px;
                 text-overflow: -o-ellipsis-lastline;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 3;
                line-clamp: 3;
                -webkit-box-orient: vertical;
              }
              .vux-x-icon {
                fill: #999;
                float: right;
              }
            }
          }
        }
        li:last-child {
          border-bottom: none;
        }
    }
  }
    .transfer_p{
      padding: 10px 20px;
      height: 30px;
      margin-top: 10px;
      span,em{
          width: 60px;
          height: 30px;
          text-align: center;
          line-height: 32px;
          font-size: 16px;
          border-radius: 5px;
          color: #fff;
          letter-spacing: 1px;
      }
      span{
          float: right;
          background-color:#2abf72;
      }
      em{
          float: left;
          background-color: #ceaa6c;
      }
  }
  .aaSpan{
    float: left;
    margin-left: -240px;
    font-size: 16px;
    color: #999;
    font-weight: 700;
  }


</style>
<style>
.weui-wepay-flow__bd {
  width: 100%;
}
.el-message-box {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90% !important;
}
</style>
